package com.smarth.zhizulian.utils;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;

import com.smarth.zhizulian.R;


public class DialogUtils {
    private static ProgressDialog progressDialog = null;

    public static void showProgressDialog(Context context, String msg) {
        if (progressDialog == null && context != null && !((Activity)context).isFinishing()) {
            progressDialog = new ProgressDialog(context);
            // 在屏幕上单击dialog不会消失
            progressDialog.setCanceledOnTouchOutside(false);
            progressDialog.setMessage(msg);
            progressDialog.show();
        }
    }

    public static void showNetWorkAccess(Context context) {
        if (progressDialog == null && context != null && !((Activity)context).isFinishing()) {
            progressDialog = new ProgressDialog(context);
            // 在屏幕上单击dialog不会消失
            progressDialog.setCanceledOnTouchOutside(false);
            progressDialog.setMessage(context.getString(R.string.network_access));
            progressDialog.show();
        }
    }

    public static void closeProgressDialog() {
        if (progressDialog != null) {
            progressDialog.cancel();
            progressDialog = null;
//            System.gc();
        }
    }

//    public static void showPhoneDialog(final Context context, final String phones) {
//        if (!TextUtils.isDataEmpty(phones)) {
//            final String[] strList = phones.split(" ");
//            final AlertDialog alertDialog = new AlertDialog.Builder(context).setItems(strList, new DialogInterface.OnClickListener() {
//                @Override
//                public void onClick(DialogInterface dialog, int which) {
//                    CommonUtils.callPhone(context, strList[which]);
//                }
//            }).create();
//            alertDialog.show();
//        } else {
//            KumaToast.show(context, "暂无电话");
//        }
//    }

}
